package com.xq.shop.controller;


import com.xq.shop.dto.QueryDto;
import com.xq.shop.service.ILoginLogService;
import com.xq.shop.service.IUserService;
import com.xq.shop.vo.LoginLogVo;
import com.xq.shop.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import utils.BasePage;
import utils.BaseResult;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 登录日志表 前端控制器
 * </p>
 *
 * @author gaoxiaojin
 * @since 2024-07-16
 */
@RestController
@RequestMapping("/login/log")
public class LoginLogController {

    private final ILoginLogService loginLogService;
    private final IUserService userService;

    @Autowired
    public LoginLogController(ILoginLogService loginLogService, IUserService userService) {
        this.loginLogService = loginLogService;
        this.userService = userService;
    }

    @RequestMapping("/page")
    public BaseResult<BasePage<LoginLogVo>> query(@RequestBody QueryDto dto, HttpServletRequest request) {
        userService.getInfo(request);
        BaseResult<BasePage<LoginLogVo>> result = new BaseResult<>();
        BasePage<LoginLogVo> page = loginLogService.pageQuery(dto);
        result.initializeSuccess(page);
        return result;
    }

}
